package com.xinguan.config;

import com.xinguan.filter.MyFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 陈俊行
 * @Date: 2023/11/12/16:58
 * @Description:
 */
@Configuration
public class FilterConfig {

    @Autowired
    public MyFilter myFilter;

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean<MyFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(myFilter);
        registrationBean.addUrlPatterns("/api/*");
        myFilter.exclusionUrl("http://localhost:9000/api/admins/login");
        myFilter.exclusionUrl("http://localhost:9000/api/admins/register");
        registrationBean.setName("myFilter1");
        registrationBean.setOrder(Integer.MAX_VALUE - 4);
        return registrationBean;
    }

}